﻿/*****		单选对象		**********************/

package anshe.object
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class ChooseObject extends MovieClip
	{
		public static const CLICK_THIS:String	= "clickThis";	/** 对象被点击  **/
		
		public var txtStyle:ExTextField;		/** 属性关键字 **/
		
		public function ChooseObject(flag:Boolean = false)
		{
			this.isClick = flag;
			this.txtStyle.color = 0xFFFFFF;
			this.text = "";
			
			this.addEventListener(MouseEvent.CLICK, onClickEvent);
		}
		
		/** 设置文字标签内容 **/
		public function set text(str:String):void
		{
			this.txtStyle.text = str;
		}
		
		/** 设置显示文字的颜色 **/
		public function set textColor(col:uint):void
		{
			this.txtStyle.color = col;
		}
		
		/** 设置对象点击状态标识 **/
		public function set isClick(flag:Boolean):void
		{
			if(flag)
			{
				this.gotoAndStop(2);
			}
			else
			{
				this.gotoAndStop(1);
			}
		}
		
		/** 读取对象点击状态标识 **/
		public function get isClick():Boolean
		{
			return Boolean(this.currentFrame == 2);
		}
				
		private function onClickEvent(e:MouseEvent):void
		{
			this.isClick = !this.isClick;
			
			this.dispatchEvent(new Event(ChooseObject.CLICK_THIS));
		}
	}
}